package com.springboot.scheduled.dynamic.cron;

import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 动态新改cron的线程，在整个程序启动的时候
 */
//@Component
public class ChangeCronThread implements ApplicationRunner {

    @Override
    public void run(ApplicationArguments args) throws Exception {
        new Thread(()-> {
            try{
                Thread.sleep(3000);
                TaskCronChangeConfigure.setCron("0/1 * * * * *");
                System.out.println("change cron , cron = " + TaskCronChangeConfigure.getCron());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }).start();
    }
}
